package com.tsmti.lab.controller.system;

import com.tsmti.core.common.controller.BaseCrudController;
import com.tsmti.core.common.model.AjaxJson;
import com.tsmti.shiro.annotation.RequiresPathPermission;
import com.tsmti.system.entity.Menu;
import com.tsmti.system.service.MenuService;
import com.tsmti.util.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Package：com.tsmti.lab.controller.system
 * @Class：MenuController
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/3/14 17:15
 * @Company:
 * @Version：
 * @Modified By:
 */
@Controller
@RequestMapping("/system/menu")
@RequiresPathPermission("sys:menu")
public class MenuController extends BaseCrudController<Menu,Long> {
    @Autowired
    private MenuService menuService;

    @RequestMapping("/info/{id}")
    public AjaxJson info(@PathVariable("id") String id){
        Menu menu = menuService.get(id);
        AjaxJson ajaxJson = new AjaxJson();
        ajaxJson.put("menu", menu);
        return ajaxJson;
    }

    @Override
    public void afterSave(Menu entity, HttpServletRequest request, HttpServletResponse response) {
        UserUtils.clearCache();
    }

}
